package pers.li.controller.address;

import pers.li.model.Address;
import pers.li.service.AddressService;
import pers.li.utils.PublicUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/user/updateAddress.action")
public class UpdateAddress extends HttpServlet {
    private final AddressService addressService = new AddressService();
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        Address address = PublicUtils.getObjectByRequest(Address.class, req);
        assert address != null;
        addressService.updateAddress(address);
        resp.sendRedirect("addressCenter.action");
    }
}
